extends Spatial

var shader = load("res://blockshader.shader")
var scl = 113.1
var Mat
export var CurrentColor = Color8(0,0,255)

func _ready():
	Mat=ShaderMaterial.new()
	Mat.shader=shader
	$MeshInstance.set_surface_material(0,Mat)
	$MeshInstance.get_surface_material(0).set_shader_param("scale",scl)
	update_color()

func update_color():
	if (CurrentColor.r>1.0):
		CurrentColor.r=1.0
	if (CurrentColor.g>1.0):
		CurrentColor.g=1.0
	if (CurrentColor.b>1.0):
		CurrentColor.b=1.0
	if (CurrentColor.r<0.0):
		CurrentColor.r=0.0
	if (CurrentColor.g<0.0):
		CurrentColor.g=0.0
	if (CurrentColor.b<0.0):
		CurrentColor.b=0.0
	$MeshInstance.get_surface_material(0).set_shader_param("color",CurrentColor)
